package cn.getech.data.metadata.controller;

import cn.getech.data.intelligence.common.utils.BaseRes;
import cn.getech.data.intelligence.common.utils.DataRes;
import cn.getech.data.intelligence.common.utils.NameValue;
import cn.getech.data.intelligence.common.utils.R;
import cn.getech.data.metadata.model.res.collectiontablestatistics.SystemStorageDayRes;
import cn.getech.data.metadata.model.res.collectiontablestatistics.TableHotRes;
import cn.getech.data.metadata.model.res.collectiontablestatistics.TableStatisticsRes;
import cn.getech.data.metadata.service.CollectionTableStatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Api(value="概览统计",tags={"概览统计"})
@RestController
@RequestMapping("md/collectionTableStatistics")
public class CollectionTableStatisticsController {
    @Autowired
    private CollectionTableStatisticsService collectionTableStatisticsService;
    @GetMapping("/count")    //md/collectionTableStatistics/count
    public R count(){
         collectionTableStatisticsService.generateSystemStorageDay();
        return R.ok();
    }
    @ApiOperation("统计表总数、今日新增表、今日修改表")
    @GetMapping("/tableStatistics")
    public DataRes<TableStatisticsRes> tableStatistics(){
        TableStatisticsRes tableStatisticsRes = collectionTableStatisticsService.tableStatistics();

        return BaseRes.okWithData(tableStatisticsRes);
    }

    @ApiOperation("各系统存储趋势图")
    @GetMapping("/systemStorageDay30")
    public DataRes<SystemStorageDayRes> systemStorageDay30(){
        SystemStorageDayRes systemStorageDayRes = collectionTableStatisticsService.systemStorageDay30();

        return BaseRes.okWithData(systemStorageDayRes);
    }

    @ApiOperation("热门元数据top10")
    @GetMapping("/tableHot10")
    public DataRes<List<TableHotRes>> tableHot10(){
        List<TableHotRes> tableHotRes = collectionTableStatisticsService.tableHot10();

        return BaseRes.okWithData(tableHotRes);
    }

    @ApiOperation("各系统存储情况")
    @GetMapping("/systemStorage")
    public DataRes<List<Map<String,Object>>> systemStorage(){
        List<Map<String,Object>> list = collectionTableStatisticsService.systemStorage();

        return BaseRes.okWithData(list);
    }
}
